﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Zombie_Demo.Utilities;

namespace Zombie_Demo.World
{
    public class Player
    {
        private Point position;
        private Texture2D sprite;
        private Vector2 spriteOrigin;

        public Vector2 Position
        {
            get { return new Vector2((int)position.X, (int)position.Y); }
        }

        public Player()
        {
            position = new Point(0, 0);
            spriteOrigin = new Vector2(16, 16);
        }

        public void Load()
        {
            sprite = ContentLibrary.GetTexture("Player");
        }

        public void Update()
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Up) || Keyboard.GetState().IsKeyDown(Keys.W))
                position.Y -= 2;
            else if (Keyboard.GetState().IsKeyDown(Keys.Down) || Keyboard.GetState().IsKeyDown(Keys.S))
                position.Y += 2;

            if (Keyboard.GetState().IsKeyDown(Keys.Right) || Keyboard.GetState().IsKeyDown(Keys.D))
                position.X += 2;
            else if (Keyboard.GetState().IsKeyDown(Keys.Left) || Keyboard.GetState().IsKeyDown(Keys.A))
                position.X -= 2;
        }

        public void Draw(SpriteBatch spriteBatch, float rotation)
        {
            spriteBatch.Draw(sprite, new Vector2((int)position.X, (int)position.Y), null, Color.White, rotation, spriteOrigin, 1, SpriteEffects.None, 0);
        }
    }
}
